import Vue from 'vue'
import Vuex from 'vuex'

// import app from './modules/app'
// import user from './modules/user'
// import permission from './modules/permission'
// import enhance from './modules/enhance'
import getters from './getters'

Vue.use(Vuex)

// 遍历引入modules文件 reduce()累加目录
const modulesFiles = require.context('./modules', true, /\.js$/)
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
}, {})


export default new Vuex.Store({
  modules,
// : {
//     app,
//     user,
//     permission,
//     enhance
//   },
  state: {},
  mutations: {},
  actions: {},
  getters
})
